﻿using System;
using System.Collections.Generic;

using System.Text;

using Xeno.Core;
using Xeno.Module;
namespace Xeno.Physics
{
    public class XenoMeshCollider : XenoCollider
    {

        public IntPtr _Data { get; set; }
        float[] verts;
        int[] indices;
        IntPtr vp, tp;
        public XenoMeshCollider(string name, XenoNode attached)
            : base(name, attached)
        {
            Attached = attached;


            XenoMesh msh = Attached.Mesh;
            verts = new float[msh.Vertices.Count * 3];
            indices = new int[msh.Triangles.Count * 3];

            for (int i = 0; i < msh.Vertices.Count; i++)
            {
                XenoVertex v = msh.Vertices[i];
                verts[i * 3] = v.Position.X;
                verts[i * 3 + 1] = v.Position.Y;
                verts[i * 3 + 2] = v.Position.Z;
            }
            for (int i = 0; i < msh.Triangles.Count; i++)
            {
                XenoTriangle t = msh.Triangles[i];
                indices[i * 3] = t.V1;
                indices[i * 3 + 1] = t.V2;
                indices[i * 3 + 2] = t.V3;

            }


            List<XenoNode> managers = Attached.GraphOwner.RootNode.AllWithType(typeof(XenoPhysicsManager), null);
            XenoNode man = managers[0];



        }

    }
}
